package com.ww.java8.datetime;

import java.time.LocalTime;
import java.time.ZoneId;

/**
 * TODO
 *
 * @author wanggw
 * @date 2024-02-21 23:26:10
 */
public class LocalTimeDemo {

    public static void main(String[] args) {
        String noNotifyLcsTime = "00:00-11:30";
        String[] times = noNotifyLcsTime.split("-");
        if (times.length != 2) {
            throw new IllegalArgumentException("时间格式错误，应为HH:mm-HH:mm");
        }

        LocalTime beginTime = LocalTime.parse(times[0]);
        System.out.println(beginTime);
        LocalTime endTime = LocalTime.parse(times[1]);
        System.out.println(endTime);
        LocalTime now = LocalTime.now(ZoneId.systemDefault());
        System.out.println(now);
        if (now.isBefore(endTime)) {
            System.out.println("在配置11点半之前");
        }
        if (now.isAfter(beginTime)) {
            System.out.println("在配置凌晨之后");
        }
    }

    private static void test1() {
        LocalTime time = LocalTime.of(13, 20, 20);
        int hour = time.getHour();
        int minute = time.getMinute();
        int second = time.getSecond();
        System.out.println("hour: " + hour + ", minute: " + minute + ", second: " + second);
    }
}
